﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


using System.ComponentModel;
using System.ComponentModel.Design;
using System.Windows.Forms;
using System.Windows.Forms.Design;


using System.Drawing;
using System.Drawing.Design;

using DotSpatial.Controls;

using DotSpatial.Data;
using DotSpatial.Symbology.Forms;
using DotSpatial.Symbology;

namespace HaGisPack
{
    class LabelSetupEditor : UITypeEditor
    {
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            IWindowsFormsEditorService DialogProvider;
            DialogProvider = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

            DotSpatial.Symbology.Forms.LabelSetup dlgLabelSetup = new LabelSetup();

            if (DialogProvider != null)
            {

                dlgLabelSetup.Layer = (value as LabelLayer);
                //dlgLabelSetup.ShowDialog();
                //DialogProvider.ShowDialog(dlgLabelSetup);
                if (DialogProvider.ShowDialog(dlgLabelSetup) == DialogResult.OK)
                {
                    return dlgLabelSetup.Layer;
                }
                else
                {
                    return value;
                }
            }
            else
                return value;
        }

        public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
        {
            return UITypeEditorEditStyle.Modal;
            //return base.GetEditStyle(context);
        }



    }
}
